package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.mapper.DtsUserAccountMapper;
import com.qf.pojo.DtsUserAccount;
import com.qf.service.DtsUserAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class DtsUserAccountServiceImpl implements DtsUserAccountService {

    @Autowired
    DtsUserAccountMapper userAccountMapper;

    @Override
    public DtsUserAccount queryById(Integer id) {
        LambdaQueryWrapper<DtsUserAccount> qw = new LambdaQueryWrapper<>();
        qw.eq(DtsUserAccount::getUserId,id);
        DtsUserAccount userAccount = userAccountMapper.selectOne(qw);
        return userAccount;
    }

    @Override
    public void updateByUserIdAndSettlementRate(Integer userId, String settlementRate) {
        DtsUserAccount userAccount = new DtsUserAccount();
        userAccount.setModifyTime(new Date());
        userAccount.setSettlementRate(Integer.valueOf(settlementRate));
        LambdaQueryWrapper<DtsUserAccount> qw = new LambdaQueryWrapper<>();
        qw.eq(DtsUserAccount::getUserId,userId);
        userAccountMapper.update(userAccount,qw);
    }
}
